#!/usr/bin/env python3
# coding=utf-8
import os
#原来的前缀
oldPrefix='XQC'
#新前缀
newPrefix='Huangww'
for dirpath, _, filenames in os.walk('.'):
    for filename in filenames:
        if filename.startswith(oldPrefix):
            oldFile = os.path.join(dirpath,filename)
            newFile = os.path.join(dirpath,filename.replace(oldPrefix,newPrefix,2))
            print newFile
            inFile = open(oldFile)
            outFile = open(newFile,'w')
            replacements = {oldPrefix:newPrefix}
            for line in inFile:
                for src,target in replacements.iteritems():
                    line = line.replace(src,target)
                outFile.write(line)
            inFile.close()
            outFile.close()
            os.remove(oldFile)
